package hospital.controller;

import hospital.model.hosp.Schedule;
import hospital.result.Result;
import hospital.service.ScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author
 * @description:
 */
@Api(tags = "医院排班管理")
@RestController
@RequestMapping("/admin/hosp/schedule")
//@CrossOrigin //允许跨域访问
public class ScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    /**
     * @Author yang
     * @Description //TODO 通过医院编号hoscode和科室编号depcode获取排班规则数据
     * @Param
     * @return
     **/
    @ApiOperation("通过医院编号hoscode和科室编号depcode获取排班规则数据")
    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(@PathVariable Integer page,
                                  @PathVariable Integer limit,
                                  @PathVariable String hoscode,
                                  @PathVariable String depcode){
//        System.out.println(page+" "+limit+" "+hoscode+" "+depcode+" ");
        Map<String,Object> map=scheduleService.getScheduleRule(page,limit,hoscode,depcode);
        return Result.ok(map);
    }

    /**
     * @Author yang
     * @Description //TODO 根据医院编号hoscode 科室编号depcode 工作日期workDate查询出排班的详情
     * @Param
     * @return
     **/
    @ApiOperation("排班详情")
    @GetMapping("getDetailSchedule/{hoscode}/{depcode}/{workDate}")
    public Result getDetailSchedule(@PathVariable String hoscode,
                                            @PathVariable String depcode,
                                            @PathVariable String workDate){
        List<Schedule> list=scheduleService.getDetailSchedule(hoscode,depcode,workDate);
        return Result.ok(list);
    }

    /**
     * @Author yang
     * @Description //TODO 自动生成排班接口
     * @Param
     * @return
     **/
    @ApiOperation("自动生成排班接口")
    @GetMapping("getAllSchedule/{hoscode}")
    public Result getAllSchedule(@PathVariable String hoscode){
        scheduleService.getAllSchedule(hoscode);
        return Result.ok();
    }
}
